<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <cc:interface>
        <cc:attribute name="manageBean" required="true"/>
    </cc:interface>

    <cc:implementation>
        <h:panelGrid id="crudMenuPanel" columns="4">
            <h:commandButton id="newBtn" value="#{msgs['label.button.new']}" action="#{cc.attrs.manageBean.clear}" immediate="true" 
                             rendered="#{cc.attrs.manageBean.state eq 'DEFAULT'}">
                <f:ajax render="@form" execute="@form"/>
                <f:setPropertyActionListener target="#{cc.attrs.manageBean.state}" value="#{'INSERT'}"/>
            </h:commandButton>
            <h:commandButton id="saveBtn" value="#{msgs['label.button.save']}" action="#{cc.attrs.manageBean.save}" 
                             rendered="#{cc.attrs.manageBean.state eq 'INSERT' || cc.attrs.manageBean.state eq 'EDIT'}">
                <f:ajax render="@form" execute="@form"/>
                <f:setPropertyActionListener target="#{cc.attrs.manageBean.state}" value="#{'DEFAULT'}"/>
            </h:commandButton>
            <h:commandButton id="searchBtn" value="#{msgs['label.button.search']}" action="#{cc.attrs.manageBean.search}" immediate="true"
                             rendered="#{cc.attrs.manageBean.state eq 'SEARCH' || cc.attrs.manageBean.state eq 'DEFAULT'}">
                <f:ajax render="@form" execute="@form"/>
                <f:setPropertyActionListener target="#{cc.attrs.manageBean.state}" value="#{'SEARCH'}"/>
            </h:commandButton>
            <h:commandButton id="cancelBtn" value="#{msgs['label.button.cancel']}" action="#{cc.attrs.manageBean.clear}" immediate="true"
                             rendered="#{cc.attrs.manageBean.state eq 'INSERT' || cc.attrs.manageBean.state eq 'SEARCH' || cc.attrs.manageBean.state eq 'EDIT'}">
                <f:ajax render="@form" execute="@form"/>
                <f:setPropertyActionListener target="#{cc.attrs.manageBean.state}" value="#{'DEFAULT'}"/>
            </h:commandButton>
        </h:panelGrid>
    </cc:implementation>
</html>